package tq.com.tqteacher.model;

import org.json.JSONObject;

import tq.com.download.TQDownloadManager;
import tq.com.tqteacher.net.TQNetInterface;

public class TQLogin {
    static private TQLogin current = new TQLogin();
    private boolean bLogin = false;
    private String token;
    private TQUserInfo mUserInfo = new TQUserInfo();

    static public TQLogin getCurrent(){
        return current;
    }
    public boolean isLogin(){
        return bLogin;
    }

    public TQUserInfo getUserInfo(){
        return mUserInfo;
    }
    public void refresh(JSONObject pObject){
        if(pObject == null)return;

        token = pObject.optString("tk");
        TQNetInterface.setToken(token);


        JSONObject profile = pObject.optJSONObject("profile");
        if(profile != null){
            mUserInfo.refresh(profile);
        }
    }

    public String getToken(){
        return token;
    }
}
